<html>
    <head>
        <meta name="layout" content="main">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
        <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
        <script  type="text/javascript" >
        $(document).ready( function(){
                $(".example1").on("click", function(event) {
                        event.preventDefault();
                        // $("#canv")为指定截取部分的id
                        html2canvas($("#canv"), {
                        allowTaint: true,
                        taintTest: false,
                        onrendered: function(canvas) {
                            canvas.id = "mycanvas";
                            //生成base64图片数据
                            var dataUrl = canvas.toDataURL();
                            var newImg = document.createElement("img");
                            newImg.src =  dataUrl;
                            window.location.href=dataUrl;//跳转至指定页面
                            document.body.appendChild(newImg);
                        }
                    });
                }); 
             
        });
         
        </script>
    </head>
    <body>
        <div class="" style="background-color: #abc;">
            计算机天堂测试html5页面截图
            <br>jsjtt.com
        </div>
         <div id="canv">1212123123123</div>
        <textArea id="textArea" col="20" rows="10" ></textArea>
        <input class="example1" type="button" value="button">
        生成界面如下：
    </body>
</html>
